package com.ai5suoai.ams.entity;


import com.ai5suoai.ams.web.vo.ToEntity;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.List;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Document(collection = "authority")
public class Authority implements Serializable, IToVo<Authority>, ToEntity<Authority> {

    @Id
    private String id;
    @NotNull
    @Size(max = 50)
    private String name;

    private List<String> urls;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Authority() {
    }

    public Authority(String name) {
        this.name = name;
    }

    public Authority(String name, List<String> urls) {
        this.name = name;
        this.urls = urls;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Authority authority = (Authority) o;

        return id != null ? id.equals(authority.id) : authority.id == null && (name != null ? name.equals(authority.name) : authority.name == null);

    }

    public List<String> getUrls() {
        return urls;
    }

    public void setUrls(List<String> urls) {
        this.urls = urls;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (urls != null ? urls.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Authority{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", urls=" + urls +
                '}';
    }

    @Override
    public Authority toVo() {
        return this;
    }

    @Override
    public Authority toEntity() {
        return this;
    }
}
